package com.yet.container;

public interface Container extends Comparable<Container> {

	void start();

	void stop();

	int getOrder();

	default State getState() {
		return new State(this.toString(), true, "");
	};

	@Override
	default int compareTo(Container o) {
		return Integer.compare(getOrder(), o.getOrder());
	}

	/**
	 * 容器状态
	 */
	static class State {
		private String name;// 容器名称
		private boolean started;// 是否启动
		private String info;// 其他信息

		public State(String name, boolean started) {
			super();
			this.name = name;
			this.started = started;
		}

		public State(String name, boolean started, String info) {
			super();
			this.name = name;
			this.started = started;
			this.info = info;
		}

		@Override
		public String toString() {
			return "Container [name=" + name + ", started=" + started + ", info=" + info + "]";
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public boolean isStarted() {
			return started;
		}

		public void setStarted(boolean started) {
			this.started = started;
		}
		
		public String getInfo() {
			return info;
		}

		public void setInfo(String info) {
			this.info = info;
		}
	}
}
